#include <iostream>
#include <vector>

using namespace std;

class Solution 
{
public:
    int search(vector<int>& nums, int target) 
    {
        int right = nums.size() - 1;
        int left = 0;

        while (left <= right)
        {
            int mid = (left + right) / 2;
            if (target > nums[mid])
            {
                left = mid + 1;
            }
            else if (target < nums[mid])
            {
                right = mid - 1;
            }
            else
                return mid;
        }

        return -1;
    }

};

int main()
{
    int n1 = 9;
    vector<int> v1{ -1,0,3,5,9,12 };

    Solution xz;
    int n = xz.search(v1, n1);

    cout << n << endl;
	return 0;
}